home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / djgpp / emu387 / e54.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-21  |  1.1 KB  |  60 lines

  1. #include "emu.h"
  2. #include "rmov.h"
  3. #include "compare.h"
  4.  
  5. void emu_54()
  6. {
  7.   if (modrm > 0277)
  8.   {
  9.     // fucom st(i)
  10.     if (empty())
  11.       return;
  12.     if (empty(modrm&7))
  13.     {
  14.       setcc(SW_C3|SW_C2|SW_C0);
  15.       return;
  16.     }
  17.     int c = compare(st(), st(modrm&7));
  18.     int f;
  19.     if (c & COMP_SNAN)
  20.     {
  21.       exception(EX_I);
  22.       f = SW_C3 | SW_C2 | SW_C0;
  23.     }
  24.     else
  25.       switch (c)
  26.       {
  27.         case COMP_A_LT_B:
  28.           f = SW_C0;
  29.           break;
  30.         case COMP_A_EQ_B:
  31.           f = SW_C3;
  32.           break;
  33.         case COMP_A_GT_B:
  34.           f = 0;
  35.           break;
  36.         case COMP_NOCOMP:
  37.           f = SW_C3 | SW_C2 | SW_C0;
  38.           break;
  39.       }
  40.     setcc(f);
  41.     
  42.   }
  43.   else
  44.   {
  45.     // frestor
  46.     void *addr = get_modrm();
  47.     int i, tag_word;
  48.  
  49.     control_word = *(int *)(addr+0) & 0xffff;
  50.     status_word = *(int *)(addr+4) & 0xffff;
  51.     tag_word = *(int *)(addr+8) & 0xffff;
  52.     top = (status_word / SW_TOPS) & 3;
  53.     for (i=0; i<8; i++)
  54.     {
  55.       r_mov((long double *)(addr + 0x1c + 10), st(i));
  56.       st(i).tag = (tag_word >> (((i+top)&7)*2)) & 3;
  57.     }
  58.   }
  59. }
  60.